<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>阶层</title>
	</head>
	<body>
		<p>输入数字：</p>
		<input id="num" type="text"/>
		<br />
		<p>
			<button id="btn">阶乘</button>
		</p>
		<p>结果是：<span id="result"></span></p>
		<script>
			document.getElementById("btn").onclick=function(){
				var num=document.getElementById("num").value;
				var result=1;
				for(var i=1;i<=num;i++){
					result*=i;
				}
				document.getElementById("result").innerHTML=result
			}
		</script>
	</body>
</html>
